package com.cobra.rdd.operator.action

import org.apache.spark.{SparkConf, SparkContext}

object Spark07_RDD_Operator_Aggregate {
  def main(args: Array[String]): Unit = {

    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("Spark07_RDD_Operator_aggregate")
    val sc = new SparkContext(sparkConf)
    val rdd = sc.makeRDD(List(4,2,3,1))
    //aggregateByKey:初始值只会参与分区内计算
    //aggregate: 还会参与分区间的运算
    val i = rdd.aggregate(0)(_+_,_+_)
    println(i)
    sc.stop()
  }
}
